package com.jinke.api.modules.app.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

@Getter
public enum MemberType {


    USER(0, "普通用户"),
    ADMIN(1, "员工"),
    OUT_SEA_USER(2, "海外仓用户"),
    ;

    @EnumValue
    private final int value;
    private final String desc;

    MemberType(final int value, final String desc) {
        this.value = value;
        this.desc = desc;
    }

    @JsonValue
    public int getValue() {
        return this.value;
    }

    // 提供静态方法根据整数值查找枚举实例
    public static MemberType fromValue(int value) {
        for (MemberType memberType : values()) {
            if (memberType.getValue() == value) {
                return memberType;
            }
        }
        throw new IllegalArgumentException("Invalid value: " + value);
    }
}